<html>
    <head>
        <title>留言管理系统</title>
        <script type="text/javascript">
            function dodel(id){
                if(confirm("确定要删除吗？")){
                    window.location="action.php?action=del&id="+id;
                }
            }

        </script>
    </head>
    <body>
    <center>


        <h3>留言板信息</h3>
        <table width="880" border="1">
            <tr>
                <th>留言id</th><th>姓名</th><th>电话</th>
                <th>邮箱</th><th>留言时间</th><th>内容</th>
                <th>操作</th>
            </tr>
            <?php
            //1.导入配置文件
            require("dbconn.php");

            $sql = "select * from liuyan";
            $result = $mysqli->query($sql); //执行操作

            while ($row = $result->fetch_assoc()) {
                echo '<tr>';
                echo '<td>' . $row["id"] . '</td>';
                echo '<td>' . $row["name"] . '</td>';
                echo '<td>' . $row["tel"] . '</td>';
                echo '<td>' . $row["email"] . '</td>';
                echo '<td>' . $row["addtime"] . '</td>';
                echo '<td>' . $row["content"] . '</td>';
                echo "<td>
<a href='javascript:dodel({$row['id']})'>删除</a>
<a href='edit.php?id={$row['id']}'>修改 </a>
<a href='huifu.php?id={$row['id']}'>回复 </a>
</td>";//edit.php后面只传值?id=123  到了edit页面以后要利用这个值
                echo '</tr>';
                $hf_sql = "select * from huifu where liu_id = '{$row["id"]}'";
                $huifu_result = $mysqli->query($hf_sql);
                while($hf_row = $huifu_result->fetch_assoc()){
                    //你在这里写表格
                    echo '<tr>';
                    echo '<td>&nbsp;</td>';
                    echo '<td colspan=6>';
                    echo  $hf_row['id'].'========'.$hf_row['name'] .$hf_row['email']. '===';
                    echo '</td>';
                    echo '</tr>';
                }
            }
            //<a href='action.php?action=del&id=({$row['id']})'>删除</a>因为添加删除确认效果，使用js
            //<a href='javascript:dodel({$row['id']})'>删除</a>  换成这种
            //$result = $mysqli->query($sql);
            //关闭数据库连接
            $mysqli->close();
            ?>
        </table>

    </center>
    <table border="1">
        <tr>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td colspan="3">dsada</td>
        </tr>
    </table>
</body>
</html>